﻿#ifndef pst_GeomtryActorGenerator_H
#define pst_GeomtryActorGenerator_H

#include <QObject>
#include <QStringList>
#include <vtkSmartPointer.h>

class vtkActor;
class vtkDataSet;
class vtkPlane;
class vtkPolyData;
class vtkClipPolyData;
class vtkAppendPolyData;
class vtkPolyDataMapper;
class vtkDataSetSurfaceFilter;

namespace pst
{
    class GeomtryActorGenerator : public QObject
    {
        Q_OBJECT

    public:
        GeomtryActorGenerator(QObject* parent);
        ~GeomtryActorGenerator();

    public:
        void setFileNameList(const QStringList& fileName);
        QStringList getFileNameList() const;

        void setIsActiveClip(bool isActiveClip);
        bool getIsActiveClip() const;

        void setClipPlaneNormalDirection(double normalDirection[3]);
        double* getClipPlaneNormalDirection();

        void setClipPlaneOrigin(double origin[3]);
        double* getClipPlaneOrigin();

        // 返回值 0：全部成功 1：部分成功 2：全部失败
        int updateActor();

        vtkSmartPointer<vtkPolyData> getGeometryPolyData();

        vtkSmartPointer<vtkActor> getActor();

        QString getErrorMessage() const;

    private:
        int readGeometryFromFile();

    private:
        QStringList m_fileName;
        bool m_isGeometryRead;

        bool m_isActiveClip;
        double m_clipPlaneNormalDirection[3];
        double m_clipPlaneOrigin[3];

        //vtkSmartPointer<vtkDataSet> m_dataSet;
        vtkSmartPointer<vtkPlane> m_clipPlane;
        vtkSmartPointer<vtkClipPolyData> m_clipFilter;
        vtkSmartPointer<vtkPolyDataMapper> m_mapper;
        vtkSmartPointer<vtkActor> m_actor;
        vtkSmartPointer<vtkAppendPolyData> m_appendPolyData;
        vtkSmartPointer<vtkPolyData> m_geometryPolyData;
        QString m_errorMessage;
    };

}
#endif
